package com.luo.chengrui.module.sa.dal.mysql.commontree;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.luo.chengrui.module.sa.dal.dataobject.commontree.CommonTreeDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import com.luo.chengrui.module.sa.controller.admin.commontree.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 通用树 Mapper
 *
 * @author 诚睿
 */
@Mapper
public interface CommonTreeMapper extends BaseMapperX<CommonTreeDO> {

    default PageResult<CommonTreeDO> selectPage(CommonTreePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CommonTreeDO>()
                .eqIfPresent(CommonTreeDO::getKindId, reqVO.getKindId())
                .eqIfPresent(CommonTreeDO::getCode, reqVO.getCode())
                .eqIfPresent(CommonTreeDO::getShortCode, reqVO.getShortCode())
                .eqIfPresent(CommonTreeDO::getNodeKindId, reqVO.getNodeKindId())
                .likeIfPresent(CommonTreeDO::getName, reqVO.getName())
                .eqIfPresent(CommonTreeDO::getRemark, reqVO.getRemark())
                .eqIfPresent(CommonTreeDO::getParentId, reqVO.getParentId())
                .eqIfPresent(CommonTreeDO::getSequence, reqVO.getSequence())
                .eqIfPresent(CommonTreeDO::getVersion, reqVO.getVersion())
                .eqIfPresent(CommonTreeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CommonTreeDO::getFullId, reqVO.getFullId())
                .likeIfPresent(CommonTreeDO::getFullName, reqVO.getFullName())
                .orderByDesc(CommonTreeDO::getId));
    }

    default List<CommonTreeDO> selectList(CommonTreeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CommonTreeDO>()
                .eqIfPresent(CommonTreeDO::getKindId, reqVO.getKindId())
                .eqIfPresent(CommonTreeDO::getCode, reqVO.getCode())
                .eqIfPresent(CommonTreeDO::getShortCode, reqVO.getShortCode())
                .eqIfPresent(CommonTreeDO::getNodeKindId, reqVO.getNodeKindId())
                .likeIfPresent(CommonTreeDO::getName, reqVO.getName())
                .eqIfPresent(CommonTreeDO::getRemark, reqVO.getRemark())
                .eqIfPresent(CommonTreeDO::getParentId, reqVO.getParentId())
                .eqIfPresent(CommonTreeDO::getSequence, reqVO.getSequence())
                .eqIfPresent(CommonTreeDO::getVersion, reqVO.getVersion())
                .eqIfPresent(CommonTreeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CommonTreeDO::getFullId, reqVO.getFullId())
                .likeIfPresent(CommonTreeDO::getFullName, reqVO.getFullName())
                .orderByDesc(CommonTreeDO::getId));
    }

    default List<CommonTreeDO> selectList(CommonTreeDO commonTreeDO) {
        QueryWrapper<CommonTreeDO> queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(commonTreeDO);
        return this.selectList(queryWrapper);
    }


    List<CommonTreeDO> getCommonTreeAllList(@Param("params") CommonTreeExportReqVO exportReqVO);
}
